package com.dapao.controller;

import com.dapao.pojo.Time;
import com.dapao.service.TimeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/appointments")
public class TimeController {

    @Autowired
    private TimeService timeService;

    @PostMapping("/time-slots")
    public Time addTimeSlot(@RequestBody Time timeSlot) {
        timeService.addTimeSlot(timeSlot);
        return timeSlot;
    }

    @GetMapping("/available-time-slots")
    public List<Time> getAvailableTimeSlots() {
        return timeService.getAvailableTimeSlots();
    }

    @GetMapping("/common-available-time-slot")
    public Time findCommonAvailableTimeSlot() {
        return timeService.findCommonAvailableTimeSlot();
    }
}
